package com.crm.controller;

import com.crm.pojo.common.PageResult;
import com.crm.pojo.common.Result;
import com.crm.pojo.dto.DictDto;
import com.crm.pojo.vo.DictVo;
import com.crm.service.DictService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/system/dict")
public class DictController {
    @Autowired
    private DictService dictService;
    @GetMapping("/data/type/{dict}")
    public Result<List<DictVo>> dict(@PathVariable String dict) {
        Result<List<DictVo>> result = new Result<>();
        result.setCode(200);
        result.setMessage("操作成功");
        result.setData(dictService.dict(dict));
        return result;
    }

    @GetMapping("/type/list")
    public PageResult list(@RequestParam(required = false) String dictName,
                           @RequestParam(required = false) String dictType,
                           @RequestParam(required = false) String status,
                           @RequestParam(value = "params[beginTime]", required = false) String beginTime,
                           @RequestParam(value = "params[endTime]", required = false) String endTime){
        DictDto dictDto = new DictDto();
        dictDto.setDictName(dictName);
        dictDto.setDictType(dictType);
        dictDto.setStatus(status);
        dictDto.setBeginCreateTime(beginTime);
        dictDto.setEndCreateTime(endTime);

        return dictService.page(dictDto);
    }


}